// 规格选项列表上移的方法
export function useArrayMoveUp(arr, index) {
    swapArray(arr, index, index - 1)
}

// 规格选项列表下移的方法
export function useArrayMoveDown(arr, index) {
    swapArray(arr, index, index + 1)
}

function swapArray(arr, index1, index2) {
    arr[index1] = arr.splice(index2, 1, arr[index1])[0]
    return arr
}

// 排序规格选项
export function sortCard(action, index, list) {
    if (action == 'up') {
        useArrayMoveUp(list, index)
    } else {
        useArrayMoveDown(list, index)
    }
}
